<?php
//  news/Form/NewsSearch.php
class Form_NewsSearch extends Zend_Form
{

    protected $_noDecorator = array(
        'ViewHelper', 
        'Errors'
    );

    public function cluBuild($params)
    {
    	$this->setMethod('POST');
//	    $e = $params['view']->hvnUrl(array('module' => 'news', 'action'=>'search', 'view' => $this->view));
//    	$this->setAction($e);

    	$this->setAction($params['action_url']);
		
	    $myValidator = new Zend_Validate_Regex('/^[A-Z0-9_\s\-]*$/i'); //alpha, num, space, -, _
        $myValidator->setMessage(t(60), Zend_Validate_Regex::NOT_MATCH);
		$this->addElementPrefixPath('Clu_Filter', 'Clu/Filter/', 'filter');
		
		//add title
        $title = new Zend_Form_Element_Text('title', 
                         array('disableLoadDefaultDecorators' => true,
//                               'required'   => true,             
                               'class' => 'inputText'));
        
        $title->addDecorators($this->_noDecorator)
        	 ->addValidator($myValidator);
        $this->addElement($title);
        
        //add keywords
        $keywords = new Zend_Form_Element_Text('keywords', 
                         array('disableLoadDefaultDecorators' => true,
//                             'required'   => true,             
                               'class' => 'inputText'));
        $keywords->addDecorators($this->_noDecorator)
        	 	->addValidator($myValidator);
        $this->addElement($keywords);
        
        //add category
        $category = new Zend_Form_Element_MultiCheckbox('category',  
                         array('disableLoadDefaultDecorators' => true
                         ));
    	$mCategory = new category_Model_Category();
        $mCategory->setTables('news');
        foreach($mCategory->getRootType('Root_News') as $e) {
            $category->addMultiOption($e['id'], $e['name']);
        }             
        $category->addDecorators($this->_noDecorator);
        $this->addElement($category);
        
        
        //add description
        $description = new Zend_Form_Element_Text('description',
                            array('disableLoadDefaultDecorators' => true,
                    //                                'required' => true
                            'class' => 'inputText'));
        
        $description->addDecorators($this->_noDecorator)
        	 		->addValidator($myValidator);
        $this->addElement($description);
        
        // add start date
        $start_date = new Zend_Form_Element_Text('start_date', 
                         array('disableLoadDefaultDecorators' => true,
//                             'required'   => true,             
                               'class' => 'inputText'));
        $start_date->addDecorators($this->_noDecorator);
        $start_date->size = 8; 
        $this->addElement($start_date);
        
        //add finish date
        $finish_date = new Zend_Form_Element_Text('finish_date', 
                         array('disableLoadDefaultDecorators' => true,
//                             'required'   => true,             
                               'class' => 'inputText'));
        $finish_date->addDecorators($this->_noDecorator);
        $finish_date->size = 8; 
        $this->addElement($finish_date);
        
        //add news per page
 		$news_per_page = new Zend_Form_Element_Select('news_per_page',  
                         array('disableLoadDefaultDecorators' => true));
        $news_per_page->addMultiOption(10,t(62))
               				->addMultiOption(20,t(63))
                           	->addMultiOption(30,t(64))
                           	->addMultiOption(40,t(65))
                           	->addMultiOption(50,t(66))
                           	->addDecorators($this->_noDecorator);
        $this->addElement($news_per_page);
        
        
        // add the submit button
		$submit = new Zend_Form_Element_Submit('submit', array('disableLoadDefaultDecorators' => true, 
                                                           'label' => t(67) ));
        
        $submit->addDecorators($this->_noDecorator);
        $this->addElement($submit);

		if($params['cluSearchMode'] == 'simpleSearch')
			return;
         //status
        $status = new Zend_Form_Element_Select('status',  
                         array('disableLoadDefaultDecorators' => true,
                                'required' => true)); 
        $status->addMultiOption('all','--'.t(61).'--')
        	   ->addMultiOption('published',t(34))
               ->addMultiOption('queued',t(35))
               ->addMultiOption('unpublished',t(36))
               ->addMultiOption('deleted',t(37))
               ->addDecorators($this->_noDecorator);

        $this->addElement($status);
    }
}
?>